home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / BASIC / LIB / EVENTSHELL / EXTENSION / FontPick (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1995-12-25  |  10KB  |  221 lines

  1.  Module FontPick
  2.  -----------------------------------------------------------------------
  3.  FontPick Handling Routines (version 1.07 25-Dec-95)
  4.  -----------------------------------------------------------------------
  5.  Public Methods Supported:
  6.    FN_shell_FontPick_Init          Initialises module
  7.    PROCshell_AttachPopupFontPicker Attaches the FontPicker to a window/icon
  8.    PROCshell_FontPicker_SelectFont
  9.    PROCshell_FontPicker_SetTitle
  10.  Responses to events raised by other modules
  11.    PROCshell_FontPickerOpen
  12.  Private Methods Supported:
  13.    FN_FontPicker_Selection
  14.    FN_FontPicker_Maker
  15.    FN_FontPicker_WatchHandler
  16.    FN_FontPicker_WatchHandler2
  17.    FN_FontPicker_Click
  18.    PROCshell_FontPicker_UpdateDisplay
  19.  Message Strings required by module
  20.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  21.  Public routines..
  22.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  23. %"*|Start FN_shell_FontPick_Init
  24. _shell_FontPick_Init
  25.  Define Constants
  26. )&_c_FontPick_Height_Icon%      = 26
  27. *&_c_FontPick_Height_Inc_Icon%  = 27
  28. +&_c_FontPick_Height_Dec_Icon%  = 28
  29. ,&_c_FontPick_Aspect_Icon%      = 30
  30. -&_c_FontPick_Aspect_Inc_Icon%  = 31
  31. .&_c_FontPick_Aspect_Dec_Icon%  = 32
  32.  the size icons should be a contiguous block..
  33. 1&_c_FontPick_Size08_Icon%      = 15
  34. 2&_c_FontPick_Size10_Icon%      = 16
  35. 3&_c_FontPick_Size12_Icon%      = 17
  36. 4&_c_FontPick_Size14_Icon%      = 18
  37. 5&_c_FontPick_Size18_Icon%      = 19
  38. 6&_c_FontPick_Size24_Icon%      = 20
  39. 7&_c_FontPick_Size28_Icon%      = 21
  40. 8&_c_FontPick_Size36_Icon%      = 22
  41. 9&_c_FontPick_Size48_Icon%      = 23
  42. :&_c_FontPick_Size72_Icon%      = 24
  43. <%_c_FontPick_Font_Icon%        = 7
  44. =&_c_FontPick_Weight_Icon%      = 10
  45. >&_c_FontPick_Style_Icon%       = 13
  46. ?%_c_FontPick_Font_M_Icon%      = 8
  47. @&_c_FontPick_Weight_M_Icon%    = 11
  48. A&_c_FontPick_Style_M_Icon%     = 14
  49. C&_c_FontPick_Try_Icon%         = 34
  50. D%_c_FontPick_Cancel_Icon%      = 1
  51. E%_c_FontPick_OK_Icon%          = 0
  52. F&_c_FontPick_Display_Icon%     = 35
  53. HH_c_FontPick_WindowName$       = "fontpick"   : 
  54.  Template identifier
  55. J&_c_FontPick_MaxHeight% = 99 :
  56. K&_c_FontPick_MinHeight% = 6  :
  57. M&_c_FontPick_MaxAspect% = 1000 :
  58. N&_c_FontPick_MinAspect% = 10   :
  59.  Define variables
  60. Q9_m_FontPick_DBoxHandle%   = -1 : 
  61.  DBox window handle
  62. R[_m_FontPick_NotifyFN$     = "" : 
  63.  FN to call when selection is made in fontpicker dbox
  64. SO_m_FontPick_WindowHandle% = -1 : 
  65.  Handle of window containing display icon
  66. TT_m_FontPick_DisplayIcon%  = -1 : 
  67.  Handle of icon to display resulting selection
  68. V!_m_FontPick_CurrentFont$ = ""
  69. W _m_FontPick_CurrentX_Pt  = 0
  70. X _m_FontPick_CurrentY_Pt  = 0
  71. Y+_m_FontPick_DBoxTitle$   = "FontPicker"
  72. [$_m_FontPick_AllowSystemFont% = 
  73. _!*|extract FN_FontPicker_Maker
  74. `(*|extract FN_FontPicker_WatchHandler
  75. a)*|extract FN_FontPicker_WatchHandler2
  76. b!*|extract FN_FontPicker_Click
  77. c%*|extract FN_FontPicker_Selection
  78. e!*|Stop FN_shell_FontPick_Init
  79. i+*|Start PROCshell_AttachPopupFontPicker
  80. shell_AttachPopupFontPicker( wh%, menuic%, dispic%, notify_fn$, preopen_FN$ )
  81. shell_WindowLoaded( _c_FontPick_WindowName$ ) 
  82.  wh% > 0 
  83.  menuic% >= 0 
  84. shell_IconSetButtonType( wh%, menuic%, 3 )
  85. shell_EvntAdd_PopUpMenu( 
  86. shell_GetWindowIdentifier( wh% ), menuic%, dispic%, -1, notify_fn$, preopen_FN$,  _POPUP_TYPE_FONTPICK )
  87. oJ   
  88.  99, 
  89. shell_MessageOneArg( "SHELLMSG37", _c_FontPick_WindowName$ )
  90. r**|Stop PROCshell_AttachPopupFontPicker
  91. v+*|Start PROCshell_FontPicker_SelectFont
  92. shell_FontPicker_SelectFont( font_name$, x_pt, y_pt )
  93. y)_m_FontPick_CurrentFont$ = font_name$
  94. z#_m_FontPick_CurrentX_Pt  = x_pt
  95. {#_m_FontPick_CurrentY_Pt  = y_pt
  96. **|Stop PROCshell_FontPicker_SelectFont
  97. )*|Start PROCshell_FontPicker_SetTitle
  98. shell_FontPicker_SetTitle( title$ )
  99. #_m_FontPick_DBoxTitle$ = title$
  100. (*|Stop PROCshell_FontPicker_SetTitle
  101.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  102.  Responses to events raised by other modules..
  103.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  104. $*|Start PROCshell_FontPickerOpen
  105. *|!PROCshell_FontPickerOpen
  106. !*|!Opens the fontpicker dbox.
  107. shell_FontPickerOpen( window_handle%, display_icon%, menu_icon%, notify_FN$, preopen_FN$ )
  108. ._m_FontPick_WindowHandle% = window_handle%
  109. -_m_FontPick_DisplayIcon%  = display_icon%
  110. *_m_FontPick_NotifyFN$     = notify_FN$
  111.  _m_FontPick_DBoxHandle% = -1 
  112. shell_CreateWindowStatic( _c_FontPick_WindowName$, _m_FontPick_DBoxHandle% )
  113. shell_AttachBumpHandler( _m_FontPick_DBoxHandle%, _c_FontPick_Height_Icon%, _c_FontPick_Height_Inc_Icon%, _c_FontPick_Height_Dec_Icon%, _c_FontPick_MinHeight%, _c_FontPick_MaxHeight%, 1, 
  114. , "" , "" )
  115. shell_AttachBumpHandler( _m_FontPick_DBoxHandle%, _c_FontPick_Aspect_Icon%, _c_FontPick_Aspect_Inc_Icon%, _c_FontPick_Aspect_Dec_Icon%, _c_FontPick_MinAspect%, _c_FontPick_MaxAspect%, 1, 
  116. , "" , "" )
  117. shell_AttachFontMenu( _m_FontPick_DBoxHandle%, _c_FontPick_Font_M_Icon%, _c_FontPick_Font_Icon%, "_FontPicker_Selection", "_FontPicker_Maker" )
  118. shell_AttachClickSelect( _m_FontPick_DBoxHandle%, -1, "_FontPicker_Click" )
  119. shell_AttachIconWatch( _m_FontPick_DBoxHandle%, _c_FontPick_Height_Icon%, "_FontPicker_WatchHandler2" )
  120. shell_AttachIconWatch( _m_FontPick_DBoxHandle%, _c_FontPick_Aspect_Icon%, "_FontPicker_WatchHandler2" )
  121. shell_AttachHelpTag( _m_FontPick_DBoxHandle%, -1, "fpdbox" )
  122. shell_FontMenu_DisallowSystemFont
  123. shell_WindowRetitle( _m_FontPick_DBoxHandle%, _m_FontPick_DBoxTitle$ )
  124. shell_FontPicker_SetFont ( _m_FontPick_CurrentFont$ )
  125. shell_FontPicker_UpdateDisplay
  126. shell_OpenWindowStatic( _m_FontPick_DBoxHandle% )
  127. shell_WindowMoveToPopUpPos( window_handle%, menu_icon%, _m_FontPick_DBoxHandle% )
  128. #*|Stop PROCshell_FontPickerOpen
  129.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  130.  Private module routines
  131.  :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  132. (*|Start PROCshell_FontPicker_SetFont
  133. shell_FontPicker_SetFont( font$ )
  134.  pos%, pos2%
  135. pos% = 
  136.  font$, "." )
  137.  pos% = 0 
  138. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Font_Icon%, font$, -1 )
  139. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Weight_Icon%, "<none>", -1 )
  140. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Style_Icon%, "<none>", -1 )
  141. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Font_Icon%, 
  142.  font$, pos% - 1 ), -1 )
  143. &  pos2% = 
  144.  font$, ".", pos% + 1 )
  145.  pos2% = 0 
  146. s    
  147. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Weight_Icon%, 
  148.  font$, pos% + 1, pos2% - 1 ), -1 )
  149. \    
  150. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Style_Icon%, "<none>", -1 )
  151. z    
  152. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Weight_Icon%, 
  153.  font$, pos% + 1, pos2% - 1 - pos% ), -1 )
  154. h    
  155. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Style_Icon%, 
  156.  font$, pos2% + 1 ), -1 )
  157. '*|Stop PROCshell_FontPicker_SetFont
  158. #*|Start FN_FontPicker_Selection
  159. _FontPicker_Selection( window_handle%, icon_handle%, selection$ )
  160. shell_FontPicker_SetFont( selection$ )
  161. )_m_FontPick_CurrentFont$ = selection$
  162. shell_FontPicker_UpdateDisplay
  163. "*|Stop FN_FontPicker_Selection
  164. .*|Start PROCshell_FontPicker_UpdateDisplay
  165. shell_FontPicker_UpdateDisplay
  166.  Read the current status of the dbox and update the font display
  167.  icon accordingly..
  168.  x_pt, y_pt, font_handle%
  169. Wy_pt = 
  170. shell_IconGetData( _m_FontPick_DBoxHandle%, _c_FontPick_Height_Icon% ) )
  171. hx_pt = y_pt * ( 
  172. shell_IconGetData( _m_FontPick_DBoxHandle%, _c_FontPick_Aspect_Icon% ) ) / 100 )
  173. shell_Fonts_FindFont( _m_FontPick_CurrentFont$, x_pt, y_pt, font_handle% )
  174. shell_Icon_SetFont( _m_FontPick_DBoxHandle%, _c_FontPick_Display_Icon%, font_handle% )
  175. "_m_FontPick_CurrentX_Pt = x_pt
  176. "_m_FontPick_CurrentY_Pt = y_pt
  177. -*|Stop PROCshell_FontPicker_UpdateDisplay
  178. *|Start FN_FontPicker_Maker
  179. _FontPicker_Maker( menu_handle% )
  180. *|Stop FN_FontPicker_Maker
  181. *|Start FN_FontPicker_Click
  182. _FontPicker_Click( window_handle%, icon_handle% )
  183.  void%, value$
  184.  icon_handle% >= _c_FontPick_Size08_Icon% 
  185.  icon_handle% <= _c_FontPick_Size72_Icon% 
  186. J  value$ = 
  187. shell_IconGetData( _m_FontPick_DBoxHandle%, icon_handle% )
  188. shell_IconPutData( _m_FontPick_DBoxHandle%, _c_FontPick_Height_Icon%, value$, 
  189. shell_EnsurePoll
  190. shell_FontPicker_UpdateDisplay
  191.  icon_handle% 
  192.  _c_FontPick_Cancel_Icon%
  193. 5    
  194. shell_CloseWindow( _m_FontPick_DBoxHandle% )
  195.  _c_FontPick_OK_Icon%
  196. 5    
  197. shell_CloseWindow( _m_FontPick_DBoxHandle% )
  198. '    
  199.  _m_FontPick_NotifyFN$ <> "" 
  200.       void% = 
  201. ( "FN" + _m_FontPick_NotifyFN$ + "( " + 
  202. ( 34 ) + _m_FontPick_CurrentFont$ + 
  203. ( 34 ) + "," + 
  204.  _m_FontPick_CurrentX_Pt + "," + 
  205.  _m_FontPick_CurrentY_Pt + " )" )
  206.         
  207. *    
  208.  _m_FontPick_DisplayIcon% <> -1 
  209. p      
  210. shell_IconPutData( _m_FontPick_WindowHandle%, _m_FontPick_DisplayIcon%, _m_FontPick_CurrentFont$, 
  211.          
  212. *|Stop FN_FontPicker_Click
  213. *&*|Start FN_FontPicker_WatchHandler
  214. _FontPicker_WatchHandler( value$ )
  215. shell_FontPicker_UpdateDisplay
  216. /%*|Stop FN_FontPicker_WatchHandler
  217. 3'*|Start FN_FontPicker_WatchHandler2
  218. _FontPicker_WatchHandler2( value$ )
  219. shell_FontPicker_UpdateDisplay
  220. 8&*|Stop FN_FontPicker_WatchHandler2
  221.